package io.renren.modules.medical.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.Constant;
import io.renren.modules.medical.dao.WebSocketInterDao;
import io.renren.modules.medical.entity.WebSocketInterEntity;
import io.renren.modules.medical.service.WebSocketInterService;
import io.renren.modules.medical.vo.weixinVo.ApiChatHistory;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Luo Sheng
 * @school YiBin university
 * @create 2023-03-29 23:18
 */
@Service("webSocketInterService")
public class WebSocketInterServiceImpl extends ServiceImpl<WebSocketInterDao, WebSocketInterEntity> implements WebSocketInterService {
    /**
     * 获取未查看记录集合
     */
    @Override
    public Integer getNoneVisitCount(Long sendId, Long sendToId) {
        LambdaQueryWrapper<WebSocketInterEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(sendId != null, WebSocketInterEntity::getSendId, sendId);
        queryWrapper.eq(sendToId != null, WebSocketInterEntity::getSendToId, sendToId);
        queryWrapper.eq(WebSocketInterEntity::getIsVisited, Constant.VisitStatus.NVISITED);
        return this.count(queryWrapper);
    }

    /**
     * 获取历史消息记录
     */
    @Override
    public List<ApiChatHistory> getHistory(Long page, Long limit, Long sendId, Long sendToId) {
        return baseMapper.getHistoryMsg(page, limit, sendId, sendToId);
    }

    @Override
    public Integer clearNoneVisit(Long sendId, Long sendToId) {
        Integer count = baseMapper.clearNoneVisit(sendId, sendToId);
        return null;
    }
}
